<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:sec="http://www.springframework.org/security/facelets/tags">

<h:body>
	<ui:composition template="/templates/templateCRUD.xhtml">
		<ui:param name="tituloCadastro" value="Cadastro de Avisos" />
		<ui:param name="tituloPesquisa" value="Pesquisa de Avisos" />
		<ui:param name="tituloGrid" value="Lista de Avisos" />
		<ui:param name="mbean" value="${avisoMB}" />
		<ui:define name="cadastro">
			<p:tabView>
				<p:tab title="Dados Aviso">
					<p:focus for="tituloCadastro" />
					<h:panelGrid columns="3">
						<h:outputText value="Médico (*): " />
						<p:selectOneMenu value="#{mbean.bean.medico}"
							disabled="#{mbean.readOnly}" label="Médico" required="true">
							<f:selectItems value="#{mbean.medicos}" var="medico"
								itemLabel="#{medico.funcionario.usuario.nome}"
								id="medicoCadastro" />
							<f:converter converterId="medicoConverter" />
						</p:selectOneMenu>
						<p:message for="medicoCadastro" showDetail="true"
							showSummary="true" />

						<h:outputText value="*Titulo: " />
						<p:inputText value="#{mbean.bean.titulo}"
							disabled="#{mbean.readOnly}" size="54" maxlength="50"
							required="true" label="Titulo" id="tituloCadastro" />
						<p:message for="tituloCadastro" showDetail="true"
							showSummary="true" />

						<h:outputText value="Descricao:" />
						<p:inputTextarea value="#{mbean.bean.descricao}"
							disabled="#{mbean.readOnly}" cols="54" rows="5" required="false"
							label="Descricão" id="descricaoCadastro" />
						<p:message for="descricaoCadastro" showDetail="true"
							showSummary="true" />

						<h:outputText value="*Dia Semana: " />
						<p:selectOneMenu value="#{mbean.bean.diaSemana}"
							disabled="#{mbean.readOnly}" label="Dia Semana" required="true">
							<f:selectItems value="#{mbean.diasSemana}" var="diaSemana"
								itemLabel="#{diaSemana.nome}" id="diaSemanaCadastro" />
						</p:selectOneMenu>
						<p:message for="diaSemanaCadastro" showDetail="true"
							showSummary="true" />

					</h:panelGrid>
				</p:tab>
			</p:tabView>
		</ui:define>

		<ui:define name="pesquisa">
			<p:focus for="nomePesquisa" />
			<h:panelGrid columns="4" cellpadding="4">
				<h:outputText value="Titulo:" />
				<p:inputText value="#{mbean.beanSearch.titulo}" size="54"
					maxlength="50" id="nomePesquisa" />

				<h:outputText value="Médico: " />
				<p:selectOneMenu value="#{mbean.beanSearch.medico}">
					<sec:ifAllGranted roles="ROLE_ADMIN">
						<f:selectItem itemLabel="#{msg.opcaoSelecionarCombo}"
							itemValue="#{null}" />
					</sec:ifAllGranted>
					<f:selectItems value="#{mbean.medicos}" var="medico"
						itemLabel="#{medico.funcionario.usuario.nome}" />
					<f:converter converterId="medicoConverter" />
				</p:selectOneMenu>
			</h:panelGrid>
		</ui:define>

		<ui:define name="gridPesquisa">
			<p:column>
				<f:facet name="header">
					<h:outputText value="Médico" />
				</f:facet>
				<h:outputText value="#{registro.medico.funcionario.usuario.nome}" />
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="Titulo" />
				</f:facet>
				<h:outputText value="#{registro.titulo}" />
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="Dia" />
				</f:facet>
				<h:outputText value="#{registro.diaSemana.nome}" />
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="Descrição" />
				</f:facet>
				<h:outputText value="#{registro.descricao}" />
			</p:column>
		</ui:define>
	</ui:composition>
</h:body>
</html>
